# pip install kafka-python
from kafka import KafkaProducer

if __name__ == '__main__':
    # 创建生产者
    producer = KafkaProducer(bootstrap_servers="master:9092,node2:9092,node2:9092")

    # 生产数据
    producer.send(topic="bigdata", value="python".encode("UTF-8"))

    # 关闭连接
    producer.close()
